package iso3.pt.action;

import iso3.pt.dao.PtDAO;
import iso3.pt.model.Alumno;
import iso3.pt.model.Evaluacion;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;

public class MostrarNotas extends ActionSupport implements Preparable{

	private PtDAO dao;
	private Alumno alum;
	private List<Evaluacion> listaEvaluaciones;
	private String tipoLogin, username, password;
	
	
	public PtDAO getDao() {
		return dao;
	}

	public void setDao(PtDAO dao) {
		this.dao = dao;
	}

	public Alumno getAlum() {
		return alum;
	}

	public void setAlum(Alumno alum) {
		this.alum = alum;
	}

	public List<Evaluacion> getListaEvaluaciones() {
		return listaEvaluaciones;
	}

	public void setListaEvaluaciones(List<Evaluacion> listaEvaluaciones) {
		this.listaEvaluaciones = listaEvaluaciones;
	}

	public String getTipoLogin() {
		return tipoLogin;
	}

	public void setTipoLogin(String tipoLogin) {
		this.tipoLogin = tipoLogin;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String userName) {
		this.username = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public void prepare() throws Exception {
		dao= PtDAO.getInstance();
	}
	
	public String execute(){
		Map<String,Object> session=ActionContext.getContext().getSession();
		alum= (Alumno)session.get("alum");
		listaEvaluaciones= dao.getEvaluacionesOrderedByAsignatura(alum.getDni());
		username= Integer.toString(alum.getDni());
		password= alum.getPassword();
		tipoLogin= (String)session.get("tipoLogin");
		return "ok";
	}

}
